home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
examples
/
insight
/
plugins
/
mybias0.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
6KB
|
156 lines
; $Id: mybias0.pro,v 1.4 1997/04/22 17:12:33 rob Exp $
;
; Copyright (c) 1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;+
; FILE:
; mybias0.pro
;
; PURPOSE:
; This file contains an example Analysis PlugIn that biases data,
; without a dialog. Note only the Apply callback is used.
; (See mybias.pro for an example with a normal Analysis dialog.)
;
; CONTENTS:
; CALLBACK ROUTINES
; fun ApplyMyBias0 - main entry point
;
; REGISTRATION FUNCTION
; fun MyBias0 - registers the PlugIn
;
;-
; *****************************************************************************
; CALLBACK ROUTINES
; *****************************************************************************
; -----------------------------------------------------------------------------
;
; Purpose: Get data and bias it (called when PlugIn menu item selected).
; Use the data selected in the vis window, else prompt user.
; Fuction returns 1B on success, else 0B.
;
function ApplyMyBias0, $
CIDs=CIDs, $ ; OUT: command ID list from INSPUT/INSVIS calls
GROUP=wGroup, $ ; IN: group leader widget ID
DATA_NAME=dataName, $ ; IN: name of data selected in visualization window
_EXTRA=extra ; IN: information to pass to commands
; ---------------------------------------------------------
; Catch errors.
; ---------------------------------------------------------
CATCH, error
if (error ne 0) then begin
CATCH, /CANCEL
void = DIALOG_MESSAGE(!ERR_STRING, DIALOG_PARENT=wGroup)
RETURN, 0B
endif
; ---------------------------------------------------------
; Get the data.
; ---------------------------------------------------------
; If no data selected, prompt the user for data.
;
if (dataName eq '') then $
inputData = INSGET( $ ; prompt the user for data
COUNT=count, $
DIMS_LIST=1, $
NAME=dataNameUse, $
/EXCLUSIVE, $
GROUP=wGroup, $
_EXTRA=extra) $
else begin
dataNameUse = dataName
inputData = INSGET( $ ; just get the data (no prompt)
dataNameUse, $
COUNT=count, $
DIMS_LIST=1, $
GROUP=wGroup, $
_EXTRA=extra)
endelse
; Return if data not obtained.
;
if (count ne 1) then $
RETURN, 0B
; ---------------------------------------------------------
; Perform biasing.
; ---------------------------------------------------------
minVal = MIN(inputData, MAX=maxVal)
bias = 0.3 * (maxVal - minVal)
newData = inputData + bias
; ---------------------------------------------------------
; Put the new data into Insight.
; ---------------------------------------------------------
description = 'Biased "' + dataNameUse + '" by ' + $
STRING(STRCOMPRESS(bias, /REMOVE_ALL)) + '.'
outputName = 'Bias0 Output'
INSPUT, $
newData , $ ; the data
DESCRIPTION = description, $ ; data description
NAME = outputName, $ ; try this data name
NEW_NAME = outputNameUsed, $ ; the data name actually used
REPLACE = 2, $ ; prompt user if name conflict
COUNT = count, $ ; returned # of items put
CIDs = CIDs, $ ; command ID list
GROUP = wGroup, $ ; widget group leader
_EXTRA = extra ; extra information
; Return if "put" failed.
;
if (count ne 1) then $
RETURN, 0B
; ---------------------------------------------------------
; Visualize new data item.
; ---------------------------------------------------------
INSVIS, $
outputNameUsed, $ ; name of data item
TYPE = 'plot', $ ; visualization type
MODE = 'new', $ ; insert | new | overlay
CIDs = CIDs, $ ; command ID list
GROUP = wGroup, $ ; widget group leader
_EXTRA = extra ; extra information
; ---------------------------------------------------------
; Successful return.
; ---------------------------------------------------------
RETURN, 1B
end ; ApplyMyBias0
; *****************************************************************************
; REGISTRATION FUNCTION
; *****************************************************************************
; -----------------------------------------------------------------------------
;
; Purpose: Register the Analysis PlugIn.
;
function MyBias0
; Return the Analysis PlugIn Registration Structure.
;
RETURN, { $
type: 'Analysis_PlugIn', $ ; PlugIn type
title: 'My Bias 0', $ ; PlugIn title
purpose: 'Bias by 30%.', $ ; PlugIn purpose
main_proc: '', $ ; (no GUI, so empty)
apply_func: 'ApplyMyBias0', $ ; apply callback
version: '5.0', $ ; IDL version
revision: '1.0' $ ; PlugIn version
}
end ; MyBias0
; -----------------------------------------------------------------------------